package com.example.yiqinmanagersystem.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

@ApiModel(description = "响应实体封装类")
@Data
@NoArgsConstructor
public class ResponseResult<T> {

    @ApiModelProperty("状态码")
    protected String code;

    @ApiModelProperty("提示消息")
    protected String message;

    @ApiModelProperty("数据条数")
    protected Integer count=0;

    @ApiModelProperty("数据")
    protected T data;

    public ResponseResult(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResponseResult(T data, Integer count) {
        this.data = data;
        this.count = count;
    }

    public ResponseResult(String code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResponseResult(String code, String message, T data, Integer count) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.count = count;
    }

    public ResponseResult(ResponseCode responseCode, T data){
        this(responseCode.getCode(),responseCode.getMsg(),data);
    }
    public ResponseResult(ResponseCode responseCode,int count ,T data){
        this(responseCode.getCode(),responseCode.getMsg(),data,count);
    }
    public ResponseResult(ResponseCode responseCode){
        this(responseCode.getCode(),responseCode.getMsg(),null);
    }
    public ResponseResult(ResponseCode responseCode,String msg,T data){
        this(responseCode.getCode(),msg,data);
    }
}
